package com.richman.view;




import javax.swing.JPanel;
import javax.swing.JPopupMenu;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;

import com.richman.controller.DecreaseRatioClient;
import com.richman.ps38.entity.BetAdyData;
import com.richman.ps38.entity.BetDvalue;
import com.richman.ps38.entity.Event;
import com.richman.ps38.entity.HGEvent;
import com.richman.utils.Common;
import com.richman.utils.GameTimeAsc;
import com.richman.utils.ProfitAsc;
import com.richman.view.BetLogPane;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ProfitPane extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8L;
	
	private  Vector<String[]> detailsData = new Vector<String[]>();
	
	public Vector<Event> gameDetailsVec = new Vector<Event>(); 
	
	
	public RebetWindow rebetWnd = new RebetWindow();
	
	//BrowserPanel bp = new BrowserPanel();
	
	private JPopupMenu m_tablepopupMenu;

    
    JMenuItem rebetMenuItem = null;
    
	public int selectedRow = -1;
	
	
	MyTableModel tableMode = new MyTableModel();
	
	private  ReadWriteLock betDvaluesLock = new ReentrantReadWriteLock(); 

	Vector<BetAdyData> gamedetailsLocal = new Vector<BetAdyData>();
	
	private  ReadWriteLock gamedetailsLock = new ReentrantReadWriteLock(); 
	
	
	JTable table = null;

	/**
	 * Create the panel.
	 */
	public ProfitPane() {
		setLayout(new BorderLayout(0, 0));

		JPanel funBtnPane = new JPanel();
		
		JButton cleanButton = new JButton("清空数据");
		cleanButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				int n = JOptionPane.showConfirmDialog(null, "确认要清空数据吗?", "清空数据",
						JOptionPane.YES_NO_OPTION);
				if (n == JOptionPane.YES_OPTION && DecreaseRatioClient.betCtrMng != null) {
					DecreaseRatioClient.betCtrMng.clearBetAdyData();
				}
				
			}
		});
		
		cleanButton.setBounds(20, 10, 60, 20);
		
		funBtnPane.add(cleanButton);
		
		add(funBtnPane, BorderLayout.NORTH);
		
		
	    table = new JTable(tableMode);
	    
//	    table.getColumnModel().getColumn(0).setPreferredWidth(30);
//	    
//	    table.getColumnModel().getColumn(2).setPreferredWidth(120);
//	    table.getColumnModel().getColumn(3).setPreferredWidth(130);
//	    table.getColumnModel().getColumn(4).setPreferredWidth(200);
//	    table.getColumnModel().getColumn(5).setPreferredWidth(100);
//	    
//	    
//
//	    
//	    table.getColumnModel().getColumn(15).setPreferredWidth(200);
	    
	    table.setRowHeight(30);
	    
	    table.setFont(new java.awt.Font("黑体", Font.PLAIN, 15));
		
		
		JScrollPane scrollPane = new JScrollPane(table);
		add(scrollPane, BorderLayout.CENTER);
		

		
		
		table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
     	       //判断是否为鼠标的BUTTON3按钮，BUTTON3为鼠标右键  
     	       if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
     	          
     	    	 
     	    	   
     	           //弹出菜单  
     	         selectedRow = table.rowAtPoint(evt.getPoint());
     	           
     	         if(selectedRow == -1) {
     	        	 return;
     	         }
     	         
     	         
     	         String ps38betres = detailsData.elementAt(selectedRow)[13];
     	         
     	         if(ps38betres.contains("失败")) {
     	        	m_tablepopupMenu.show(table, evt.getX(), evt.getY());
     	         }

     	       }
            }  
        });
		
		

		
		
	    m_tablepopupMenu = new JPopupMenu();
	    rebetMenuItem = new JMenuItem();
	    rebetMenuItem.setText("手动补单");
	    rebetMenuItem.addActionListener(new java.awt.event.ActionListener() {  
            public void actionPerformed(java.awt.event.ActionEvent evt) {  
                //该操作需要做的事  
            	
            	try{
            		
            		boolean delSuc = false;
            		
            		rebetWnd.setgame(detailsData.elementAt(selectedRow));
            		
            		rebetWnd.setVisible(true);

            		if(delSuc == true) {
            			JOptionPane.showMessageDialog(null, "已解除匹配", "已解除匹配", JOptionPane.DEFAULT_OPTION);
            		}

            	}catch(Exception e){
            		e.printStackTrace();
            	}

            }  
        });
		

		
	    m_tablepopupMenu.add(rebetMenuItem);

	}
	
	
	
	public void updateBetAdyTable(Vector<BetAdyData> gamedetails){
		
		try{
			gamedetailsLock.writeLock().lock();
			if(gamedetailsLocal.size() != 0)
			{
				gamedetailsLocal.clear();
			}
			for(int i = 0; i < gamedetails.size(); i++) {
				BetAdyData game = gamedetails.elementAt(i);
				gamedetailsLocal.add(game);
			}
			
			gamedetailsLock.writeLock().unlock();
				
			if(detailsData.size() != 0){
				detailsData.clear();
			}
			
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			
			int betcount = gamedetails.size();
			
			Map<String, Integer> lprofit = new HashMap<String, Integer>();
			Map<String, Integer> lbettotal = new HashMap<String, Integer>();
			Map<String, Integer> lbettimes = new HashMap<String, Integer>();
			
			int tprofit = 0;
			
			for(int i = 0; i < gamedetails.size(); i++) {
				
				BetAdyData game = gamedetails.elementAt(i);
				
				String hgbetres = "";
				
				if(game.hgbetres.equals("1")) {
					hgbetres = "成功";
				}else if(game.hgbetres.equals("2")) {
					hgbetres = "确认成功";
				}else if(game.hgbetres.equals("0")) {
					hgbetres = "注单待确认";
				}else if(game.hgbetres.equals("-1")) {
					hgbetres = "超过信用额度";
				}else if(game.hgbetres.equals("-2")) {
					hgbetres = "失败 ";
				}else if(game.hgbetres.equals("-3")) {
					hgbetres = "注单取消，投注失败 ";
				}else if(game.hgbetres.equals("-4")) {
					hgbetres = "股东限额，投注失败";
				}else {
					hgbetres = game.hgbetres;
				}
				
				
				String ps38betres = "";
				
				if(game.ps38betres.equals("")) {
					ps38betres = "失败";
				}else if(game.ps38betres.equals("2")) {
					ps38betres = "确认成功";
				}else if(game.ps38betres.equals("1")) {
					ps38betres = "成功";
				}else if(game.ps38betres.equals("0")) {
					ps38betres = "注单待确认";
				}else if(game.ps38betres.equals("-3")) {
					ps38betres = "注单取消，投注失败";
				}else if(game.ps38betres.equals("-4")) {
					ps38betres = "注单暂时无法确认,请人工确认";
				}else {
					ps38betres = game.ps38betres;
				}
				
				
				if(game.ps38rebetflag != null && game.ps38rebetflag.equals("1")) {
					ps38betres = "补单-" + ps38betres;
				}
				
				
				int totalBetTimes = 0;
				int totalBetGold = 0;
				for(int j = 0; j < gamedetails.size(); j++) {
					BetAdyData gameTmp = gamedetails.elementAt(j);
					if(gameTmp.hgeventid.equals(game.hgeventid)
					&& gameTmp.bettype.equals(game.bettype) ) {
						totalBetTimes++;
						totalBetGold += Integer.parseInt(gameTmp.hgbetgold);
					}
				}
				
				
				//{ "序号", "联赛", "时间", "球队", "投注类型", "投注盘口","合并赔率", "皇冠注单", "皇冠金额", "皇冠投注时间","皇冠结果", "PS38注单", "PS38金额 ", "PS38投注时间 ", "PS38结果"};
				
				
				//计算单场利润
				int sProfit = 0;
				String strProfit = "";
				if(game.result.contains("-")&&game.bettype.contains("让球")) {
					double homescore = Integer.parseInt(game.result.split("-")[0].replace(" ", ""));
					double awayscore = Integer.parseInt(game.result.split("-")[1].replace(" ", ""));
					
					String hometeam = game.teams.split("-vs-")[0];
					//String awayteam = game.teams.split("-vs-")[1];
					
					//String betteam = game.hgbettype.split("@")[0];
					double betratio = Double.parseDouble(game.hgbettype.split("@")[1].replace(" ", ""));
					
					double r = homescore-awayscore - Double.parseDouble(game.betpankou);
					
					if(r>0.45) {//说明主队赢球
						if(game.hgbettype.contains(hometeam)) {//投注的也是主队
							if(betratio<0.0) { //水位是负，赢投注金额
								sProfit = (int) Double.parseDouble( game.hgbetgold );
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);
							}
						}else {//投注的是客队
							if(betratio<0.0) { //水位是负，
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);															
							}else {
								sProfit = 0-(int) (Double.parseDouble( game.hgbetgold ));
							}
						}
					}else if(r>0.2) {//说明主队赢一半
						if(game.hgbettype.contains(hometeam)) {//投注的也是主队
							if(betratio<0.0) { //水位是负，赢投注金额
								sProfit = (int) Double.parseDouble( game.hgbetgold )/2;
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;
							}
						}else {//投注的是客队
							if(betratio<0.0) { //水位是负，
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;															
							}else {
								sProfit = 0-(int) (Double.parseDouble( game.hgbetgold ))/2;
							}
						}
					}else if(Math.abs(r)<0.1) {
						sProfit = 0;
					}else if(r <-0.45) {//主队输球
						if(game.hgbettype.contains(hometeam)) {//投注的也是主队
							if(betratio<0.0) { //水位是负，赢投注金额
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);								
							}else {
								sProfit = 0-(int) Double.parseDouble( game.hgbetgold );
							}
						}else {//投注的是客队
							if(betratio<0.0) { //水位是负，
								sProfit = (int) Double.parseDouble( game.hgbetgold );													
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);
							}
						}
					}else if(r <-0.2) {//主队输一半
						if(game.hgbettype.contains(hometeam)) {//投注的也是主队
							if(betratio<0.0) { //水位是负，赢投注金额
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;								
							}else {
								sProfit = 0-(int) Double.parseDouble( game.hgbetgold )/2;
							}
						}else {//投注的是客队
							if(betratio<0.0) { //水位是负，
								sProfit = (int) Double.parseDouble( game.hgbetgold )/2;													
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;
							}
						}
					}
					
					if(lprofit.get(game.league)!=null) {
						lprofit.put(game.league,lprofit.get(game.league)+sProfit );	
					}else {
						lprofit.put(game.league,sProfit );	
					}
					
					if(lbettotal.get(game.league)!=null) {
						lbettotal.put(game.league,lbettotal.get(game.league)+(int) Double.parseDouble( game.hgbetgold ) );	
					}else {
						lbettotal.put(game.league,(int) Double.parseDouble( game.hgbetgold ) );	
					}
					
					if(lbettimes.get(game.league)!=null) {
						lbettimes.put(game.league,lbettimes.get(game.league)+1 );	
					}else {
						lbettimes.put(game.league,1 );	
					}
						
					tprofit = tprofit + sProfit;
					strProfit = Integer.toString(sProfit);
				}else if(game.result.contains("-")&&game.bettype.contains("大小")) {
					double homescore = Integer.parseInt(game.result.split("-")[0].replace(" ", ""));
					double awayscore = Integer.parseInt(game.result.split("-")[1].replace(" ", ""));

					double betratio = Double.parseDouble(game.hgbettype.split("@")[1].replace(" ", ""));					
					double r = homescore+awayscore - Double.parseDouble(game.betpankou);
					if(r>0.4) {//大球赢
						if(game.hgbettype.contains("大")) {
							if(betratio<0.0) {
								sProfit = (int) Double.parseDouble( game.hgbetgold );
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);
							}
						}else {
							if(betratio<0.0) {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);
								
							}else {
								sProfit = 0-(int) (Double.parseDouble( game.hgbetgold ));
							}
						}
					}else if(Math.abs(r)<0.1) {
						sProfit = 0;
					}else if(r<-0.4) {
						if(game.hgbettype.contains("大")) {
							if(betratio<0.0) {								
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);
							}else {
								sProfit = 0-(int) (Double.parseDouble( game.hgbetgold ));
							}
						}else {
							if(betratio<0.0) {
								sProfit = (int) (Double.parseDouble( game.hgbetgold ));
								
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio);
							}
						}
					}else if(r>0.23) {
						if(game.hgbettype.contains("大")) {
							if(betratio<0.0) {
								sProfit = (int) Double.parseDouble( game.hgbetgold )/2;
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;
							}
						}else {
							if(betratio<0.0) {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;
								
							}else {
								sProfit = 0-(int) (Double.parseDouble( game.hgbetgold ))/2;
							}
						}
					}else if(r<-0.23) {
						if(game.hgbettype.contains("大")) {
							if(betratio<0.0) {								
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;
							}else {
								sProfit = 0-(int) (Double.parseDouble( game.hgbetgold ))/2;
							}
						}else {
							if(betratio<0.0) {
								sProfit = (int) (Double.parseDouble( game.hgbetgold ))/2;
								
							}else {
								sProfit = (int) (Double.parseDouble( game.hgbetgold )*betratio)/2;
							}
						}
					}
					
					
					if(lprofit.get(game.league)!=null) {
						lprofit.put(game.league,lprofit.get(game.league)+sProfit );	
					}else {
						lprofit.put(game.league,sProfit );	
					}
					
					if(lbettotal.get(game.league)!=null) {
						lbettotal.put(game.league,lbettotal.get(game.league)+(int) Double.parseDouble( game.hgbetgold ) );	
					}else {
						lbettotal.put(game.league,(int) Double.parseDouble( game.hgbetgold ) );	
					}
					
					if(lbettimes.get(game.league)!=null) {
						lbettimes.put(game.league,lbettimes.get(game.league)+1 );	
					}else {
						lbettimes.put(game.league,1 );	
					}
					
					tprofit = tprofit + sProfit;
					strProfit = Integer.toString(sProfit);
				}
				
				
				
				String[] item = {
									Integer.toString(betcount - i),//0
									game.league,
									game.time,
									game.teams,
									game.bettype,//5
									game.betpankou,
									game.mergeratio,
									game.hgbettype,
									game.hgbetgold,
									hgbetres,//10
									game.ps38bettype,
									game.ps38betgold,
									ps38betres,
									game.result,//14
									game.websitetype,//15
									strProfit
									};
				
				detailsData.add(0, item);
			}
			
			//计算
			
			for(int i= 0;i <detailsData.size();i++ ) {
				if(!detailsData.elementAt(i)[15].equals("")) {
					detailsData.elementAt(i)[15] = detailsData.elementAt(i)[15] +"/" + 
							lprofit.get(detailsData.elementAt(i)[1]) + "/" +  
							Integer.toString(tprofit);
				}
				
			}
			
			detailsData.clear();
			int i = 0;
			for( Map.Entry<String, Integer> entry: lprofit.entrySet() ) {
				String[] item = {
						Integer.toString(i+1),//0
						entry.getKey(),
						Integer.toString(lbettimes.get(entry.getKey())),
						Integer.toString(lbettotal.get(entry.getKey())),
						Integer.toString(entry.getValue()),
						Integer.toString(tprofit)
						
				};
				detailsData.add(0, item);
				i++;
			}
			
			Comparator<String[]> cmp = new ProfitAsc();
			
			Collections.sort(detailsData , cmp);
			
			for(int z = 0;z < detailsData.size(); z++) {
				detailsData.elementAt(z)[0] = Integer.toString(z+1);
			}
			
			//constructBetDvalue();

			setOneRowBackgroundColor();
			
			tableMode.updateTable();

			
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	public Vector<BetDvalue> getBetDvalus(){
		Vector<BetDvalue> vec = new Vector<BetDvalue>();
		
		betDvaluesLock.readLock().lock();
		
		
		
		for(int i = 0; i < DecreaseRatioClient.betCtrMng.betDvalues.size(); i++){
		
			
			
			
			vec.add(DecreaseRatioClient.betCtrMng.betDvalues.elementAt(i));
			

			
		}
		
		betDvaluesLock.readLock().unlock();
		
		return vec;
	}
	
	
	public Vector<BetAdyData> getBetAdyDatas(){
		
		Vector<BetAdyData> vec = new Vector<BetAdyData>();
		gamedetailsLock.readLock().lock();
		for(int i = 0; i < gamedetailsLocal.size(); i++){
			vec.add(gamedetailsLocal.elementAt(i));
		}		
		gamedetailsLock.readLock().unlock();		
		return vec;
	}
	
	
	
	
    public void setOneRowBackgroundColor() {
    	

    	
        try {  
        	
            DefaultTableCellRenderer tcr = new DefaultTableCellRenderer() {
            	
            	
  
                public Component getTableCellRendererComponent(JTable table,  
                        Object value, boolean isSelected, boolean hasFocus,  
                        int row, int column) {  

                	
                    if (row%2==1) {  
                    	setBackground(new Color(246,246,246));  
                        
                    }else{  
                        setBackground(new Color(222,222,243));  
                    	//setBackground(new Color(1,1,1));  
                      
                    }  
                    
                    setHorizontalAlignment(JLabel.CENTER);
  
                    return super.getTableCellRendererComponent(table, value,  
                            isSelected, hasFocus, row, column);  
                }  
            };  
            
            
            DefaultTableCellRenderer resRender = new DefaultTableCellRenderer() {   

                public void setValue(Object value) { //重写setValue方法，从而可以动态设置列单元字体颜色   

                   
                	String str = value.toString();
                	
    				
    				
    				if(str.contains("成功")){
    					
    					setBackground(Color.GREEN);

    				}else if(str.contains("失败")){    	
    					setBackground(Color.red);
    				}else {
    					setBackground(Color.yellow);
    				}
    				
    				
    				setForeground(Color.BLACK);
    					
    				setText((value == null) ? "" : str);
    				
    				 setHorizontalAlignment(JLabel.CENTER);

                }   

            };
            
            
            
            
            
            DefaultTableCellRenderer ratioRender = new DefaultTableCellRenderer() {   

                public void setValue(Object value) { //重写setValue方法，从而可以动态设置列单元字体颜色   

                   
                	String str = value.toString();
                	
                	
                	setForeground(Color.BLACK);
                	
    				if(Common.isNum(str)) {
    					double ratio = Double.parseDouble(str);
    					if(ratio - DecreaseRatioClient.mainWnd.getbetodd() < 0.0) {
    						setForeground(Color.red);
    	    				
    					}
    				}
    				
    				//setBackground(new Color(246,246,246)); 
    				
    				
    					
    				setText((value == null) ? "" : str);
    				
    				 setHorizontalAlignment(JLabel.CENTER);

                } 
                
                
                public Component getTableCellRendererComponent(JTable table,  
                        Object value, boolean isSelected, boolean hasFocus,  
                        int row, int column) {  

                	
                    if (row%2==1) {  
                    	setBackground(new Color(246,246,246));  
                        
                    }else{  
                        setBackground(new Color(222,222,243));  
                    	//setBackground(new Color(1,1,1));  
                      
                    }  
                    
                    setHorizontalAlignment(JLabel.CENTER);
  
                    return super.getTableCellRendererComponent(table, value,  
                            isSelected, hasFocus, row, column);  
                }  
                
                
                

            }; 
            
            
            
            
            
            
            
            int columnCount = table.getColumnCount();  
            for (int i = 0; i < columnCount; i++) {  
            	
            	String columnname = table.getColumnName(i);
            	
            	if(columnname.equals("皇冠结果") || columnname.equals("结果")) {
            		table.getColumn(columnname).setCellRenderer(resRender);
            	//	continue;
            	}else if(columnname.equals("合并赔率")){
            		table.getColumn(columnname).setCellRenderer(ratioRender);
            		
            	}else {
            		table.getColumn(columnname).setCellRenderer(tcr);
            	}
            	
            	
            }  
        } catch (Exception ex) {  
            ex.printStackTrace();  
        }  
    
    }  
	
	
	
	

    public class MyTableModel extends AbstractTableModel  
    {  
        /**
		 * 
		 */
		private static final long serialVersionUID = 10086L;
		/* 
         * 这里和刚才一样，定义列名和每个数据的值 
         */  
//        String[] columnNames =          
//        	{ "序号",  "联赛", "比赛时间", "球队", "投注类型", "投注盘口", "合并赔率",  "皇冠注单", "皇冠金额", "皇冠结果", "副网注单", "金额 ",  "结果", "赛果","副网","单场、联赛、总"};

        
        String[] columnNames =          
        	{ "序号",  "联赛", "投注场次","投注金额", "输赢金额", "总输赢"};

  
        /** 
         * 构造方法，初始化二维数组data对应的数据 
         */  
        public MyTableModel()  
        {  

        }  
  
        // 以下为继承自AbstractTableModle的方法，可以自定义  
        /** 
         * 得到列名 
         */  
        @Override  
        public String getColumnName(int column)  
        {  
            return columnNames[column];  
        }  
          
        /** 
         * 重写方法，得到表格列数 
         */  
        @Override  
        public int getColumnCount()  
        {  
            return columnNames.length;  
        }  
  
        /** 
         * 得到表格行数 
         */  
        @Override  
        public int getRowCount()  
        {         
	        if(null == detailsData){
	    		return 0;
	    	}
            return detailsData.size();  
        }  
  
        /** 
         * 得到数据所对应对象 
         */  
        @Override  
        public Object getValueAt(int rowIndex, int columnIndex)  
        {  
            //return data[rowIndex][columnIndex];
        	if(columnIndex==17) {
        		return detailsData.elementAt(rowIndex)[23];
        	}
        	return detailsData.elementAt(rowIndex)[columnIndex];
        }  
  
        /** 
         * 得到指定列的数据类型 
         */  
        @Override  
        public Class<?> getColumnClass(int columnIndex)  
        {  
        	
        	return String.class;
        	
//        	if(detailsData.size() == 0){
//        		return String.class;
//        	}
//
//            return detailsData.elementAt(0)[columnIndex].getClass();
        	
        }  
  
        /** 
         * 指定设置数据单元是否可编辑.这里设置"姓名","学号"不可编辑 
         */  
        @Override  
        public boolean isCellEditable(int rowIndex, int columnIndex)  
        {  
            return false;
        }  
          
        /** 
         * 如果数据单元为可编辑，则将编辑后的值替换原来的值 
         */  
        @Override  
        public void setValueAt(Object aValue, int rowIndex, int columnIndex)  
        {  
            detailsData.elementAt(rowIndex)[columnIndex] = (String)aValue;  
            /*通知监听器数据单元数据已经改变*/  
            fireTableCellUpdated(rowIndex, columnIndex);  
        }  
        
        public void updateTable(){
        	fireTableDataChanged();
        }
        
  
    }  

}
